package imaa.escola.disciplina.service;

import imaa.escola.instrumento.domain.Instrumento;
import imaa.escola.instrumento.repository.InstrumentoRepository;

import java.beans.PropertyEditorSupport;

import org.springframework.beans.factory.annotation.Autowired;

public class InstrumentoPropertyEditor extends PropertyEditorSupport {

	@Autowired
	private InstrumentoRepository instrumentoRepository;
	
	@Override
	public void setAsText(String text) throws IllegalArgumentException {
		Instrumento instrumento = instrumentoRepository.findOne(Long.parseLong(text));
		super.setValue(instrumento);
	}
}
